//-----------------------------------------------------------------------
// <copyright file="EmailService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class EmailService
    {
        #region Email

        public static void CreateEmail(Email email)
        {            
            try
            {
                EmailDAO emailDAO = new EmailDAO();
                emailDAO.CreateEmail(email);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateEmailException, ex);
            }
        }        

        public static void UpdateEmail(Email email)
        {            
            try
            {
                EmailDAO emailDAO = new EmailDAO();
                emailDAO.UpdateEmail(email);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateEmailException, ex);
            }
        }        

        public static void DeleteEmail(long mailID)
        {            
            try
            {
                EmailDAO emailDAO = new EmailDAO();
                emailDAO.DeleteEmail(mailID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteEmailException, ex);
            }
        }
        
        public static Email GetEmail(long mailID)
        {            
            try
            {
                EmailDAO emailDAO = new EmailDAO();
                return emailDAO.GetEmail(mailID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetEmailException, ex);
            }
        }                

        public static EmailCollection GetEmailList(EmailColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                EmailDAO emailDAO = new EmailDAO();
                return emailDAO.GetEmailList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetEmailListException, ex);
            }
        }        

        public static EmailCollection GetEmailList(EmailColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                EmailDAO emailDAO = new EmailDAO();
                return emailDAO.GetEmailList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetEmailListException, ex);
            }
        }        

	    public static EmailCollection GetEmailListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                EmailDAO emailDAO = new EmailDAO();
                return emailDAO.GetEmailListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetEmailListException, ex);
            }
        }        

        public static EmailCollection GetEmailListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                EmailDAO emailDAO = new EmailDAO();
                return emailDAO.GetEmailListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetEmailListException, ex);
            }
        }        

        #endregion
    }
}